package com.leo.blog.util;

import sun.misc.BASE64Encoder;

import java.util.Base64;

/**
 * @Classname FileBase64Util
 * @Description TODO
 * @Date 2023/3/20 13:56
 * @Created by XiongXiong
 * @Author: X.I.O
 */
public class FileBase64Util {

    /**
     * 将字节数组文件转为base64
     * @param bytes
     * @return
     */
    public static String bytesToBase64(byte[] bytes){
        String str=new BASE64Encoder().encode(bytes);
        return str;
    }

    /**
     *  将base64转为字节数组文件
     * @param base64
     * @return
     */
    public static byte[] base64ToBytes(String base64){
        byte[] bytes = Base64.getDecoder().decode(base64);
        return bytes;
    }
}
